package com.guohu.mapper;

import com.bean.WmsTBillDetails;
import com.bean.WmsTCustomer;
import com.bean.WmsTTransfer;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GuoHuMapper {
    //卖家
    @Select("select * from wms_t_customer  where custID in(select custID from wms_t_bill)")
    public List<WmsTCustomer> selSeller();
    //买家
    @Select("select * from wms_t_customer  where custID in(\n" +
            "select customerID from wms_t_bill where wms_t_bill.billID in(\n" +
            "select wms_t_bill_details.billID from wms_t_bill_details GROUP BY wms_t_bill_details.billID HAVING count(*) <= 10)) ")
    public List<WmsTCustomer> selBuyer();
    //查询卖家下所有的商品
    @Select("select * from wms_t_bill_details where billID in (select billID from wms_t_bill where customerID=#{value})")
    public List<WmsTBillDetails> selDetails(String maijia);
    //查询货物id下的所有信息
    @Select("select * from wms_t_bill_details where detailsID=#{value}")
    public WmsTBillDetails selDetailID(String detailsid);
    //插入wms_t_transfer
    @Insert("insert into wms_t_transfer(transferID,userID,transferVender,transferBuyer,transferCode,transferDate,transferState,transferEditTime,transferIsDel) values(#{transferID},#{userID},#{transferVender},#{transferBuyer},#{transferCode},#{transferDate},'1',#{transferDate},'0')")
    public void inTransfer(String transferID,String userID,String transferVender, String transferBuyer,String transferDate,String transferCode);
    //插入wms_t_trans_details
    @Insert("insert into wms_t_trans_details(tdetailsID,transferID,detailsID,tdetailsGoodsNum,tdetailsEditTime,tdetailsIsDel) values(#{tdetailsID},#{transferID},#{detailsID},#{tdetailsGoodsNum},#{transferDate},'0')")
    public void inTranDeta(String tdetailsID,String transferID,String detailsID,String tdetailsGoodsNum,String transferDate);
    //插入卖家进wms_t_bill
    @Insert("insert into wms_t_bill(billID,billTransactor,customerID,billState,billDate,billCode,billType,billFeeStore,billFeeOther,billPayable,billPaid,billEditTime,billIsDel) values(#{billID},#{userID},#{maijiaID},'0',#{transferDate},#{transferCode},'1','0','0','0','0',#{transferDate},'1')")
    public void inbillMaij(String billID,String userID,String maijiaID,String transferDate,String transferCode);
    //插入买家进wms_t_bill
    @Insert("insert into wms_t_bill(billID,billTransactor,customerID,billState,billDate,billCode,billType,billFeeStore,billFeeOther,billPayable,billPaid,billEditTime,billIsDel) values(#{biID},#{userID},#{mj},'3',#{transferDate},#{transferCode},'0',#{kucun},#{qita},#{yingshou},#{fufei},#{transferDate},'0')")
    public void inbillMj(String biID,String userID,String mj,String transferDate,String transferCode,String kucun,String qita,String yingshou,String fufei);
    //动态查询00
    @Select("<script>        select * from wms_t_transfer where 1=1\n" +
            "        <if test=\"transferVender != null and transferVender != '' \">\n" +
            "            and wms_t_transfer.transferVender = #{transferVender}\n" +
            "        </if>\n" +
            "        <if test=\"transferBuyer != null and transferBuyer != '' \">\n" +
            "            and wms_t_transfer.transferBuyer = #{transferBuyer}\n" +
            "        </if>\n" +
            "        <if test=\"date1 != null and date1 != ''\">\n" +
            "            <if test=\"date2 != null and date2 != ''\">\n" +
            "                and wms_t_transfer.transferEditTime between #{date1} and #{date2}\n" +
            "            </if>\n" +
            "        </if>\n</script>")
    public List<WmsTTransfer> selTransFer(String transferBuyer, String transferVender,String date1, String date2);
}
